import { Injectable } from '@angular/core';
import {HttpUtils} from "../utils/http.utils";
import {USER} from "./user.service";
import {ParamsModel} from "../model/params.model";

@Injectable()
export class UserInfo {
  setPortraitApi:string = '/customerUser/portrait';
  UserInfoApi:string = '/customerUser/info';
  userDetailApi:string = '/customerUser/detail';
  constructor(private api:HttpUtils,private USER:USER) { }

  getUserInfo(params:Object,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.UserInfoApi;
    pm.reqestData=params;
    pm.succCallback = success;
    this.api.get(pm);
  }
  getUserDetail(params:Object,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.userDetailApi;
    pm.reqestData = params;
    pm.succCallback = success;
    this.api.get(pm);
  }
  updatePortrait(params:Object,success:any){
    // 通过接口更新头像字段{protrait:''},如果成功则执行success
    let pm = new ParamsModel(this.USER);
    pm.url = this.setPortraitApi;
    pm.reqestData=params;
    pm.succCallback = success;
    this.api.put(pm);
  }
}
